﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using IDAL;
using Model;
using DBUtility;

namespace DAL
{
    public class TestItem_SPC:ITestItem_SPC
    {
        #region 静态变量部分
        private const string PARM_TESTITEM_PRODUCTTYPEID = "@ProductTypeID";
        private const string PARM_TESTITEM_TESTITEMNAME = "@TestItemName";
        private const string PARM_TESTITEM_ENAID = "@ENAID";
        private const string PARM_TESTITEM_STARTTIME = "@starttime";
        private const string PARM_TESTITEM_STOPTIME = "@stoptime";
        #endregion

        #region 数据检索部分
        public DataSet GetSPC(string productTypeID, string TestItemName, DateTime starttime, DateTime stoptime)
        {
            DataSet ds = new DataSet();
            SqlParameter[] testParms = GetParameters();
            testParms[0].Value = productTypeID;
            testParms[1].Value = TestItemName;
            testParms[2].Value = starttime;
            testParms[3].Value = stoptime;

            ds = sqlHelper.GetDataSet("TestItem_SPCPID_DT", "SPC", sqlHelper.ConnectionStringLocalTransaction, testParms);            
            return ds;
        }

        public DataSet GetSPCbyENA(string productTypeID, string TestItemName,string ENAID, DateTime starttime, DateTime stoptime)
        {
            DataSet ds = new DataSet();
            SqlParameter[] testParms = GetParameters1();
            testParms[0].Value = productTypeID;
            testParms[1].Value = TestItemName;
            testParms[2].Value = ENAID;
            testParms[3].Value = starttime;
            testParms[4].Value = stoptime;

            ds = sqlHelper.GetDataSet("TestItem_SPCPIDENAID_DT", "SPC", sqlHelper.ConnectionStringLocalTransaction, testParms);
            return ds;
        }
        #endregion

        #region 参数部分
        private static SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
                    new SqlParameter(PARM_TESTITEM_PRODUCTTYPEID, SqlDbType.NVarChar, 50),
                    new SqlParameter(PARM_TESTITEM_TESTITEMNAME,SqlDbType.NVarChar,50),
                    new SqlParameter(PARM_TESTITEM_STARTTIME, SqlDbType.DateTime, 8),
					new SqlParameter(PARM_TESTITEM_STOPTIME, SqlDbType.DateTime, 8)             
                };
            return parms;
        }

        private static SqlParameter[] GetParameters1()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
                    new SqlParameter(PARM_TESTITEM_PRODUCTTYPEID, SqlDbType.NVarChar, 50),
                    new SqlParameter(PARM_TESTITEM_TESTITEMNAME,SqlDbType.NVarChar,50),
                    new SqlParameter(PARM_TESTITEM_ENAID,SqlDbType.NVarChar,50),
                    new SqlParameter(PARM_TESTITEM_STARTTIME, SqlDbType.DateTime, 8),
					new SqlParameter(PARM_TESTITEM_STOPTIME, SqlDbType.DateTime, 8)             
                };
            return parms;
        }
        #endregion
    }
}
